﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Xml;
using System.Drawing;

namespace ImageEditor
{
    class TitlePanel : Panel
    {
        private String _initialText;
        private bool _initialize = false;

        public TitlePanel(String initialText)
        {
            this.Size = new Size(375, 40);
            this.Location = new Point(500, 20);
            this.BackColor = Color.Black;
            this.BorderStyle = BorderStyle.FixedSingle;
            this._initialText = initialText;
        }

        public void UpdateText(String text)
        {
            Graphics g = this.CreateGraphics();
            g.Clear(Color.Black);
            g.DrawString(text, new Font(FontFamily.GenericSerif, 14.0F), new SolidBrush(Color.White), new PointF(20, 10));
            g.Dispose();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (!_initialize)
                e.Graphics.DrawString(_initialText, new Font(FontFamily.GenericSerif, 14.0F), new SolidBrush(Color.White), new PointF(20, 10));
                _initialize = true;
        }       
    }
}
